<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <script>

    /* function sum(n, m) {
            return n + m;
    } */

    // 改成箭头函数
    /*   let sum = (n, m) => {
            return n + m;
    } */

    //如果函数体中只有一行return ，可以省略return和大括号
    // let sum = (n, m) => n + m;

    // console.log(sum(10, 20));

    // ------------------------------------------------------

    /*       // ============  嵌套函数 改成 箭头函数 
            function fn(n) {
                return function (m) {
                    return n + m;
                }
            }
            let fn = n => m => (n + m) */


    /*     // ============ 箭头函数形参 默认值
        function sum(n, m) {
            if (typeof n === 'undefined') {
                n = 0;
            }
            if (typeof m === 'undefined') {
                m = 0;
            }
            return n + m;
        }
        // 形参赋值默认值；当没有给形参传递实参的时候，执行默认值 ;
        let sum = (n = 0, m = 0) => n + m; */


    // ------------------------------------------------------

    // ======== 箭头函数里面没有 arguuments  
    let sum1 = (...arr) => {
        console.log(arr);//把每一项放在数组里面
    };
    console.log(sum1(10, 30, 40));

    let sum = (...arr) => eval(arr.join("+")); //eval 求和
    console.log(sum(10, 30, 40));


    </script>

</body>

</html>